
package com.csz.model;

import com.csz.dao.Persistencia;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/* @author Arthur F. Zanona */

public class Pontuacao extends Persistencia {
    private static final long serialVersionUID = 1L;

    private Integer ponPaiId;    
    private Double ponTotal;    
    private Pais pais;    
    private Pessoa ponPesId;

    public Pontuacao() {
    }

    public Pontuacao(Integer ponPaiId) {
        this.ponPaiId = ponPaiId;
    }

    public Integer getPaisId() {
        return ponPaiId;
    }

    public void setPaisId(Integer ponPaiId) {
        this.ponPaiId = ponPaiId;
    }

    public Double getTotal() {
        return ponTotal;
    }

    public void setTotal(Double ponTotal) {
        this.ponTotal = ponTotal;
    }

    public Pais getPais() {
        return pais;
    }

    public void setPais(Pais pais) {
        this.pais = pais;
    }

    public Pessoa getPessoa() {
        return ponPesId;
    }

    public void setPessoa(Pessoa ponPesId) {
        this.ponPesId = ponPesId;
    }

    public Integer getPonPaiId() {
        return ponPaiId;
    }

    public void setPonPaiId(Integer ponPaiId) {
        this.ponPaiId = ponPaiId;
    }
    public Integer salvar(Object obj) {
        return null;
    }

    @Override
    public void salvar() {
        String namedQuery = this.getId() == null ? Inserir : Atualizar ;
        //----- params aqui
        List<Object> params = new ArrayList<Object>();
        //---- fim params
        if ( this.getId() != null ) params.add( this.getId() );
        PreparedStatement ps = createStatementNamedQuery(namedQuery, params);
        try {
            ps.execute();
        } catch (SQLException ex) {}
    }

    public static Object consultar(Integer id) {
        return Pontuacao.consultarNamedQuery(ConsultarPorId, Arrays.asList(new Object[]{id}));
    }

    @Override
    public void remover() {
        PreparedStatement ps = createStatementNamedQuery(Remover, Arrays.asList( new Object[] { this.getId() } ));
        try {
            ps.execute();
        } catch (SQLException ex) {}
    }
   
    public static List<Object> consultar(){
        return Pontuacao.consultarNamedQuery(ConsultarTodos, Arrays.asList(new Object[]{}));
    }

    public static List<Object> consultarNamedQuery(String namedQuery, List params){
        throw new UnsupportedOperationException("Not supported yet.");
    }

        // QUERY SQL --------------------------------------------------------------------------------------------------------------
    public static final String ConsultarTodos  = "SELECT usu_id,usu_login,usu_pass FROM usuario";
    public static final String ConsultarPorId = "SELECT * FROM .. WHERE .._id = ?";
    private static final String Remover = "DELETE FROM .. WHERE .._id = ?";
    private static final String Atualizar = "UPDATE .. SET .. ";
    private static final String Inserir = "INSERT INTO .. (..) VALUES (?,?,..)";
    // FIM QUERY SQL --------------------------------------------------------------------------------------------------------------


}
